package com.dao;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class DaoFactory {
    private  static DaoFactory factory = new DaoFactory();

    private Map<String,Object> map = new ConcurrentHashMap<>();

    private DaoFactory(){

    }

    public static DaoFactory getInstance(){
        return factory;
    }

    public readerDao getreaderDao(){
        readerDao dao = (readerDao) map.get("readerDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new readerDao();
            map.put("readerDao",dao);
        }
        return dao;
    }

    public writerDao getwriterDao(){
        writerDao dao = (writerDao) map.get("writerDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new writerDao();
            map.put("writerDao",dao);
        }
        return dao;
    }

    public adminDao getadminDao(){
        adminDao dao = (adminDao) map.get("adminDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new adminDao();
            map.put("adminDao",dao);
        }
        return dao;
    }

    public searchDao getsearchDao(){
        searchDao dao = (searchDao) map.get("searchDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new searchDao();
            map.put("searchDao",dao);
        }
        return dao;
    }

    public bookDao getbookDao(){
        bookDao dao = (bookDao) map.get("bookDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new bookDao();
            map.put("bookDao",dao);
        }
        return dao;
    }

    public book_examineDao getbook_examineDao(){
        book_examineDao dao = (book_examineDao) map.get("book_examineDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new book_examineDao();
            map.put("book_examineDao",dao);
        }
        return dao;
    }

    public chapter_examineDao getchapter_examineDao(){
        chapter_examineDao dao = (chapter_examineDao) map.get("chapter_examineDao");
        if (dao != null){
            return dao;
        }
        else {
            dao = new chapter_examineDao();
            map.put("chapter_examineDao",dao);
        }
        return dao;
    }


}
